package MyOs;
import queue.*;
public class PcbPool {//由于能力限制，该PcbPool只能正常处理1~100个进程
    private int total=0;//用于存储后续队列中pcb的id
    private queue a=new linkqueue();
    public PcbPool(){
        for(int i=1;i<=100;i++)
            a.enQueue(i);
    }
    public void ShowPid(){
        while(!a.isEmpty())
            System.out.println(" "+a.deQueue().pid);
    }
    /*public void deleteAll(){
        a.clear();
    }*/
    public Pcb getOne(){
        if(!a.isEmpty()){
          total++;
          return a.deQueue();
        }
        else
            throw new IllegalArgumentException("Pcb池已经为空");
    }
    
    public void returnOne(){
      a.enQueue(total);
    }
}